/**
 * 
 */

var xmlHttp;

function login(username, password)
{ 
	alert("You hit the javaScript");
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp == null)
	{
	   alert ("Browser does not support HTTP Request");
	   return
	} 
	var url = "http://localhost:8080/TravelExpertsWeb/login/login";
	//url = url + "?username=" + username + "?password=" + password + "?sessionStatus=" + sessionStatus;
	xmlHttp.onreadystatechange = stateChanged("loginarea"); 
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}

function lookUpPackage(packId)
{
alert("You hit the javaScript");
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp == null)
	{
	   alert ("Browser does not support HTTP Request");
	   return
	} 
	var url = "http://localhost:8080/TravelExpertsWeb/packages/packages";
	url = url + "?packid=" + packid;
	xmlHttp.onreadystatechange = stateChanged("package_display"); 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged(idToReplace) 
{ 
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
	{ 
	   document.getElementById(idToReplace).innerHTML = xmlHttp.responseText; 
	} 
} 

function GetXmlHttpObject()
{ 
	var objXMLHttp = null;
	if (window.XMLHttpRequest)
	{
	   objXMLHttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
	   objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

function validateLogin(loginform)
{
	    if (loginform.username.value == "")
		{
			alert("You forgot to enter a username.");
			loginform.username.focus();
			return false;
		}
		if (loginform.password.value == "")
		{
			alert("You forgot to enter a password.");
			loginform.password.focus();
			return false;
		}
		return true;
}